package co.edu.poli.ficb.agl.automatable.graph;

import org.apache.commons.collections15.Factory;

import co.edu.poli.ficb.agl.automatable.modelo.automatas.Automata;
import co.edu.poli.ficb.agl.automatable.modelo.automatas.Estado;
import co.edu.poli.ficb.agl.automatable.modelo.automatas.EstadoImpl;

public class MyVertexFactory implements Factory<Estado> {
	
	private int n;
	
	private Automata automata;
	
	public MyVertexFactory(Automata automata) {
		n = 1;
		this.automata = automata; 
	}

	@Override
	public Estado create() {
		int i = n, c = 0;
		while(true) {
			if (automata.getEstados().contains(new EstadoImpl("S"+i))) {
				i++;
			} else {
				n = i+1;
				c = i;
				break;
			}
		}
		return new EstadoImpl("S"+String.valueOf(c));
	}
}
